package com.testdocs.server.version;

import javax.jdo.annotations.Extension;
import javax.jdo.annotations.IdGeneratorStrategy;
import javax.jdo.annotations.IdentityType;
import javax.jdo.annotations.PersistenceCapable;
import javax.jdo.annotations.Persistent;
import javax.jdo.annotations.PrimaryKey;

import com.testdocs.client.version.VersionInfo;

@PersistenceCapable (identityType = IdentityType.APPLICATION)
public class Version {
	@PrimaryKey
	@Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
	@Extension(vendorName = "datanucleus", key = "gae.encoded-pk", value = "true")
	String id;
	
	@Persistent
	private String name;
	
	@Persistent
	private String projectId;
	
	@Persistent
	private int order;
	
	public Version() {
		
	}
	
	public Version(String name, int order, String projectId) {
		this.name = name;
		this.order = order;
		this.projectId = projectId;
	}

	public String getId() {
		return id;
	}

	public void setId(String id) {
		this.id = id;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getProjectId() {
		return projectId;
	}

	public void setProjectId(String projectId) {
		this.projectId = projectId;
	}

	public VersionInfo toVersionInfo() {
		VersionInfo versionInfo = new VersionInfo();
		versionInfo.setName(name);
		versionInfo.setId(id);
		return versionInfo;
	}

	public void setOrder(int order) {
		this.order = order;
	}

	public int getOrder() {
		return order;
	}
}
